forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


? @DATETIME BUG

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Sat Aug 23, 2003 4:30 pm    Post subject: ? @DATETIME BUG Reply with quote

? @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 Confused
Bug ???
?? wrong usage.

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sat Aug 23, 2003 7:12 pm    Post subject: Reply with quote

This code displays February...

Code:
info @datetime(mmmm,33)


And this March:

Code:
info @datetime(mmmm,61)


Any clues? Confused

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Sat Aug 23, 2003 7:16 pm    Post subject: Reply with quote

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. Wink

Greetz
Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Sun Aug 24, 2003 4:20 am    Post subject: Reply with quote

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 Laughing
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
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Vic D'Elfant
Past Contributor
Past Contributor


Joined: 26 Jun 2002
Posts: 673
Location: The Netherlands

PostPosted: Sun Aug 24, 2003 12:00 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Mon Aug 25, 2003 5:43 am    Post subject: Reply with quote

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
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Mon Aug 25, 2003 1:41 pm    Post subject: Reply with quote

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
View user's profile Send private message
Vic D'Elfant
Past Contributor
Past Contributor


Joined: 26 Jun 2002
Posts: 673
Location: The Netherlands

PostPosted: Mon Aug 25, 2003 5:42 pm    Post subject: Reply with quote

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#... Smile

Vic

_________________
phpBB Development Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group