• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Time displaying worng

New Here ,
Jan 07, 2007 Jan 07, 2007

Copy link to clipboard

Copied

Hi i have a list box which show increment time,

starttime = 09:00
endtime = 18:00
Increment = 20

so this should show 09:00 to 18:00 every 20 mins

but i acually get 09:20 to 18:20

any ideas why this is happening

<select name="SMS_Time">
<option></option>
<cfset steptime1 = GetUser.starttime>
<cfloop condition="DateCompare(StepTime1, GetUser.EndTime) LT 1">
<cfoutput query="GetUser">
<cfset StepTime1 = dateadd("n", GetUser.Increment, StepTime1)>
<option value="#TimeFormat(StepTime1, "HH:mm:ss")#">#TimeFormat(StepTime1, "HH:mm")#
</option>
</cfoutput>
</cfloop>
</select>
TOPICS
Advanced techniques

Views

271

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 07, 2007 Jan 07, 2007

Copy link to clipboard

Copied

IYour code is wrong:
1. why increment the time before you output it? that is why it starts outputting @ 9:20
2. why cfoutput a query in the loop? what's the point?
3. why do a dateCompare? Just use a straight numeric comparison.

I think that this should work better. ( i haven't tested it though)

<select name="SMS_Time">
<option></option>
<cfset steptime1 = GetUser.starttime>
<cfloop condition="StepTime1 lte GetUser.EndTime">
<option value="#TimeFormat(StepTime1, "HH:mm:ss")#">#TimeFormat(StepTime1, "HH:mm")#</option>
<cfset StepTime1 = dateadd("n", GetUser.Increment, StepTime1)>
</cfloop>
</select>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 07, 2007 Jan 07, 2007

Copy link to clipboard

Copied

LATEST
Hi thanks that solved the issue, but caused another on my action page

The value "#TimeFormat(StepTime1," cannot be converted to a number
The error occurred in D:\Websites\thecraxx\InetPub\wwwroot\SMS_Insert_Schedule.cfm: line 14

12 : setLocale("English (Australian)");
13 : smsDate=lsParseDateTime(form.SMS_Date);
14 : hours=listFirst(SMS_Time,":")+listGetAt(SMS_Time,2,":")/60+listLast(SMS_Time,":")/360;
15 : smsDate=dateAdd("h",hours,smsDate);
16 : // shortcut method i forgot about


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation