ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date Function (https://www.excelbanter.com/excel-programming/289848-date-function.html)

ExcelMonkey[_56_]

Date Function
 
I have variables for year, month, day, and hour. Is there a date
function I can use to view the date as follows:

m/d/yyyy h:mm

DateFunction(year, month, day, hour)


---
Message posted from http://www.ExcelForum.com/


ExcelMonkey[_57_]

Date Function
 
I think I can use this

CurrentDate = DateSerial(CurrentYear, CurrentMonth, CurrentDay)
CurrentHour / 2

--
Message posted from http://www.ExcelForum.com


Rob van Gelder[_4_]

Date Function
 
ExcelMonkey,

DateSerial and TimeSerial
eg.

Sub test()
Dim lngYear As Long, lngMonth As Long, lngDay As Long, lngHour As Long
Dim dtm As Date

lngYear = 2004
lngMonth = 2
lngDay = 1
lngHour = 12

dtm = DateSerial(lngYear, lngMonth, lngDay) + TimeSerial(lngHour, 0, 0)

MsgBox Format(dtm, "dd-Mmm-yyyy HH:mm:ss")
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"ExcelMonkey " wrote in message
...
I have variables for year, month, day, and hour. Is there a date
function I can use to view the date as follows:

m/d/yyyy h:mm

DateFunction(year, month, day, hour)


---
Message posted from http://www.ExcelForum.com/




JE McGimpsey[_2_]

Date Function
 
One way:

myDate = DateSerial(year, month, day) + hour / 24
MsgBox Format(myDate, "m/d/yyyy h:mm")


In article ,
ExcelMonkey wrote:

I have variables for year, month, day, and hour. Is there a date
function I can use to view the date as follows:

m/d/yyyy h:mm

DateFunction(year, month, day, hour)


---
Message posted from http://www.ExcelForum.com/



All times are GMT +1. The time now is 01:33 AM.

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