ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date in VBA (https://www.excelbanter.com/excel-programming/364013-date-vba.html)

witek

Date in VBA
 
Hi guys.

I have three variables, day, month and year.

How to create a valid date from them.

CDate needs expression, but it depends on regional settings, so
CDate ("5/6/2006") will return May 6th, or June 5th depends on settings.

I need something more universal.
Does it exist?

Jim Thomlinson

Date in VBA
 
Try DateSerial something like this...

MsgBox DateSerial(2005, 5, 6)
--
HTH...

Jim Thomlinson


"witek" wrote:

Hi guys.

I have three variables, day, month and year.

How to create a valid date from them.

CDate needs expression, but it depends on regional settings, so
CDate ("5/6/2006") will return May 6th, or June 5th depends on settings.

I need something more universal.
Does it exist?


witek

Date in VBA
 
Jim Thomlinson wrote:
Try DateSerial something like this...

MsgBox DateSerial(2005, 5, 6)


Yes, Thanks.



All times are GMT +1. The time now is 03:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com