View Full Version : Solved: Date Formating?
m.azrie
01-18-2007, 12:20 AM
Hello,
is't any vba code to return any date to day first.
example :
01/03/2006 to 01/03/2006
05/03/2006 to 01/03/2006
11/04/2006 to 01/04/2006
Thanks,
JimmyTheHand
01-18-2007, 12:50 AM
This may help. Actually, it's designed to work as a worksheet function, but if you change the input parameter to date or string type, you can use it in regular code. You might have to alter it a little, (i.e. change the order of day, month, year) depending on how your system handles date.
Function ReduceDate(cell As Range) As Date
Dim a As String
a = "1/" & CStr(Month(cell.Value)) & "/" & CStr(Year(cell.Value))
ReduceDate = CDate(a)
End Function
m.azrie
01-18-2007, 01:08 AM
Hmm... I just receive interesting solution could be share to others,
CurDate = Date
NewDate = DateAdd("d",-(Day(CurDate)-1),CurDate)
I'ts works .
Bob Phillips
01-18-2007, 04:58 AM
You don't need DateAdd
CurDate = Date
NewDate = CurDate - Day(CurDate) + 1
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.