![]() |
today vs. now
i would like to use "today" in code, but i can't get it to work.
i can use "now" and it works, but i need the integer format that 'today' provides. i have tried rounding, declaring at integer, cint(now), etc. sub temp() cells(1,1)=today end sub thanks, mike allen (seems like my questions are getting simpler, not more complex like they should be) |
today vs. now
cells(1,1)=date
-- HTH RP (remove nothere from the email address if mailing direct) "mike allen" wrote in message ... i would like to use "today" in code, but i can't get it to work. i can use "now" and it works, but i need the integer format that 'today' provides. i have tried rounding, declaring at integer, cint(now), etc. sub temp() cells(1,1)=today end sub thanks, mike allen (seems like my questions are getting simpler, not more complex like they should be) |
today vs. now
There's no "today" function in VBA. However you can use the equivalent
Date function: Public Sub temp() Cells(1, 1).Value = Date End Sub In article , "mike allen" wrote: i would like to use "today" in code, but i can't get it to work. i can use "now" and it works, but i need the integer format that 'today' provides. i have tried rounding, declaring at integer, cint(now), etc. sub temp() cells(1,1)=today end sub thanks, mike allen (seems like my questions are getting simpler, not more complex like they should be) |
today vs. now
Hi Mike
how about Cells(1,1), = Format(Now(), "mm/dd/yyyy") Cheers JulieD "mike allen" wrote in message ... i would like to use "today" in code, but i can't get it to work. i can use "now" and it works, but i need the integer format that 'today' provides. i have tried rounding, declaring at integer, cint(now), etc. sub temp() cells(1,1)=today end sub thanks, mike allen (seems like my questions are getting simpler, not more complex like they should be) |
today vs. now
it does not work because it is not a builtin function. Therefore, write
your own. mine is below: Public Function Today() As Date ' Returns a date that does not contain the current time in it. Today = Now() - Time() End Function |
today vs. now
Date is the VBA equivalent to the worksheet function Today.
You can strip the time from Now using Int Int(now) demo'd from the immediate window: ? date 1/11/2005 ? int(now) 1/11/2005 ? now 1/11/2005 11:18:24 AM -- Regards, Tom Ogilvy "mike allen" wrote in message ... i would like to use "today" in code, but i can't get it to work. i can use "now" and it works, but i need the integer format that 'today' provides. i have tried rounding, declaring at integer, cint(now), etc. sub temp() cells(1,1)=today end sub thanks, mike allen (seems like my questions are getting simpler, not more complex like they should be) |
All times are GMT +1. The time now is 03:41 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com