Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Changing time zones

Using a simple 'Range("XX") = Now' I can put todays date and time onto any
cell, but only in my time zone which is GMT. How do I change the time zone
to, say EST which is 5 hours behind me?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 563
Default Changing time zones

The time that Now inserts is not necessarily GMT - it is whatever time zone
you have setup in Regional Setting

I have a subroutine with the line of code
Range("D5") = Format(Now, "H:mm")
that inserts the local time into D5 (I am on Atlantic time in Nova Scotia)

If I replace that by two lines of code
mytime = Now - (4 / 24) ' I like the
parentheses because of the way VBA presents formula)
Range("D5") = Format(mytime, "H:mm")
Or the single statement
Range("D5") = Format(Now - 4/24, "H:mm")
it inserts the time in Vancouver (Pacific) which is 4 hours behind me

And
mytime = Now + (4 / 24)
Range("D5") = Format(mytime, "H:mm")
would insert the time in Exeter, Devon

Be aware that when you go from UK to North America the dates for summer time
differ a bit. So your code might need to add 5 most times and 4 or 6 when
the two summer times are out of step.

best wishes
--
Bernard Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme

"Darren" wrote in message
...
Using a simple 'Range("XX") = Now' I can put todays date and time onto any
cell, but only in my time zone which is GMT. How do I change the time zone
to, say EST which is 5 hours behind me?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 137
Default Changing time zones

Thankyou Bernard, that's just what I need.

"Bernard Liengme" wrote:

The time that Now inserts is not necessarily GMT - it is whatever time zone
you have setup in Regional Setting

I have a subroutine with the line of code
Range("D5") = Format(Now, "H:mm")
that inserts the local time into D5 (I am on Atlantic time in Nova Scotia)

If I replace that by two lines of code
mytime = Now - (4 / 24) ' I like the
parentheses because of the way VBA presents formula)
Range("D5") = Format(mytime, "H:mm")
Or the single statement
Range("D5") = Format(Now - 4/24, "H:mm")
it inserts the time in Vancouver (Pacific) which is 4 hours behind me

And
mytime = Now + (4 / 24)
Range("D5") = Format(mytime, "H:mm")
would insert the time in Exeter, Devon

Be aware that when you go from UK to North America the dates for summer time
differ a bit. So your code might need to add 5 most times and 4 or 6 when
the two summer times are out of step.

best wishes
--
Bernard Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme

"Darren" wrote in message
...
Using a simple 'Range("XX") = Now' I can put todays date and time onto any
cell, but only in my time zone which is GMT. How do I change the time zone
to, say EST which is 5 hours behind me?


.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drop down list & Time Zones. GEM Excel Discussion (Misc queries) 2 June 29th 09 10:53 PM
Help with identifying time and time zones in a formula Mr BT[_2_] Excel Worksheet Functions 1 May 21st 09 05:23 AM
time zones Cactus-747 Excel Discussion (Misc queries) 1 April 14th 06 06:11 AM
Does Excel support Time Zones? Aaron Excel Worksheet Functions 1 March 11th 05 06:17 PM
Time Zones SteveC Excel Programming 1 September 19th 04 05:45 PM


All times are GMT +1. The time now is 12:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"