now()

1. Junior Member
Join Date
Dec 1969
Posts
11

## now()

I would like to be able to subtract 3 hours from now(), when storing date/time, since the server is actually 3 hours ahead of all the users. (I tried searching on boards for this but I&#039;m guessing with the parens it is messing up queries).<BR><BR>If someone can point me to the syntax, or any help is appreciated.<BR><BR>thanks!

2. Junior Member
Join Date
Dec 1969
Posts
11

## RE: now()

Hmm, played with it and got lucky. I used now() - .125<BR><BR>I guess the syntax is just add/subtract whatever days(or fraction of days)?

3. Senior Member
Join Date
Dec 1969
Posts
196

## RE: now()

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## If you care why...

A DATE value in VBScript (and a Date/Time value in Access, not so coincidentally, since both are based on COM VARIANTs), is actually a double precision floating point number.<BR><BR>The part of the number to the left of the decimal point [that is, the INT(someDateTime) ] is the number of days since December 30, 1899. [A negative number means a date before that date.]<BR><BR>The fractional part of the number is, indeed, the time of day expressed as a fraction of 24 hours.<BR><BR>But be careful: Doing something like <BR>&nbsp; &nbsp; Now() - 0.125<BR>does *NOT* produce another Date/Time value! Since you just did arithmetic, it converts the value of Now() to a double precision floating number (easy to do, since that&#039;s what it already is!) and then performs the math.<BR><BR>If you want to be *sure* that the result of that math will be *treated* as a date/time again, then you should do:<BR>&nbsp; &nbsp; CDate( Now() - 0.125 )<BR><BR>Much of the time, the conversion back via CDate is not needed. But it can never hurt and might help.<BR><BR>If you use the DateAdd function, though, the result *will* be a Date/Time value and you don&#039;t need to use CDate.<BR><BR>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsfctdateadd.asp<BR><BR>

5. Junior Member
Join Date
Dec 1969
Posts
11

## RE: If you care why...

Excellent info! I think I will use the DateAdd function. Thanks to both of you!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•