| View previous topic :: View next topic |
| Author |
Message |
CodeScript Moderator Team

Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Sat Aug 23, 2003 4:30 pm Post subject: ? @DATETIME BUG |
|
|
? @DATETIME BUG
| Code: |
INFO @DATETIME(dddd,1)
|
Returns sunday. 2 will return monday and so on.
But
| Code: |
INFO @DATETIME(mmmm,2)
|
should return february (or march if zero based)
but try it; It returns Jan
Bug ???
?? wrong usage. _________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Sat Aug 23, 2003 7:16 pm Post subject: |
|
|
It's because the counting starts on Jan 1st 1900. So if you feed it with the value 33,
the function will count 33 days from that starting date - that would be February, 61 days will be March.
And today will be 37856 days from 1-1-1900 - that's the first part returned from a plain @datetime() call.
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
CodeScript Moderator Team

Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Sun Aug 24, 2003 4:20 am Post subject: |
|
|
| Dr. Dread wrote: | It's because the counting starts on Jan 1st 1900. So if you feed it with the value 33,
the function will count 33 days from that starting date - that would be February, 61 days will be March. |
I had observed but could not explain why - bad at math
but I don't think the function should behave this way ?
Any way one can multiply 1 2 3 to get the valid month I think.
I was getting date / time of a directory and wanted to covert the values reurned by the API to day and month.
Of course one can use if 1 then monday and so on. _________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|
| Back to top |
|
 |
Vic D'Elfant Past Contributor


Joined: 26 Jun 2002 Posts: 673 Location: The Netherlands
|
Posted: Sun Aug 24, 2003 12:00 pm Post subject: |
|
|
Hmmmmm.... and how about this:
| Code: |
%%Date = @datetime(ddddd)
rem We start counting from 1900... Probably this will save some time
%%TimeValue = 32871
repeat
rem This @datetime should be in the same format as the date we've got from the folder
if @equal(@datetime(ddddd, %%TimeValue), %%Date)
%%ExitLoop = 1
end
%%TimeValue = @succ(%%TimeValue)
until %%ExitLoop
info The time-value of %%Date is %%TimeValue!
|
Vic _________________ phpBB Development Team |
|
| Back to top |
|
 |
CodeScript Moderator Team

Joined: 08 Jun 2003 Posts: 1060 Location: India
|
Posted: Mon Aug 25, 2003 5:43 am Post subject: |
|
|
This will work for my API function which returns month in value 1 to 12
| Code: | %m = 1
INFO @DATETIME(mmmm,@PROD(%m,30)) |
Vic
Thanks for your suggestion but :
Benchmarking shows the above one to be more than 60 times faster! than converting the date to datetimeformat and then getting the value atleast in the IDE.
Regards _________________ Regards
- CodeScript
Give your application a professional look with the VDSGUI Extension |
|
| Back to top |
|
 |
jwfv Valued Contributor

Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Mon Aug 25, 2003 1:41 pm Post subject: |
|
|
This should probably go in the wish list category, but since I saw this topic ...
I have always wished that VDS had better Date and Time functions, like adding and subtracting months and years. (And adjusting for number of days in a month or year when doing so.)
Is there a VDS .DLL with any of these functions? _________________ Joe Floyd |
|
| Back to top |
|
 |
Vic D'Elfant Past Contributor


Joined: 26 Jun 2002 Posts: 673 Location: The Netherlands
|
Posted: Mon Aug 25, 2003 5:42 pm Post subject: |
|
|
Perhaps you could use a combination of the convert.dsu and the vdstime.dll, available in Tommy's vdsdll3.
By accident I know that date/time calculations are very easy to do in C#...
Vic _________________ phpBB Development Team |
|
| Back to top |
|
 |
|