Convert Dateserial to Date

mchac

Well-known Member
Joined
Apr 15, 2013
Messages
531
What is the reverse of CLng? I have dateserial in VBA and would like to convert it to a Date. Note the dateserial is in VBA not in Excel.

Thanks in advance.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
What is the reverse of CLng? I have dateserial in VBA and would like to convert it to a Date. Note the dateserial is in VBA not in Excel.

Thanks in advance.
DateSerial(year,month,day) returns a date. DateSerial(2015,1,30) returns 1/30/2015.
 
Upvote 0
Thanks JoeMo. I my VBA I use Date which gives me 1/30/2015. The code randomly picks a date no more than 90 days prior but the result is in DateSerial (i.e. 41963). How do I convert that back to a date format in VBA?
 
Upvote 0
Thanks JoeMo. I my VBA I use Date which gives me 1/30/2015. The code randomly picks a date no more than 90 days prior but the result is in DateSerial (i.e. 41963). How do I convert that back to a date format in VBA?
Code:
Sub test()
x = 41963
MsgBox x
x = Format(x, "mm/dd/yyyy")
MsgBox x
End Sub
 
Upvote 0

Forum statistics

Threads
1,225,323
Messages
6,184,280
Members
453,227
Latest member
Slainte

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top