P PipBoy808 Member Jun 3, 2014 #1 Hi, I'm having an issue with formatting a date: Code: Dim MyDate as Date MyDate = Format(Left(Now,10), "dd.mm.yy") Weirdly, this is returning MyDate as "03:06:14" rather than "03.06.14". Can anyone tell me why? Thanks!
Hi, I'm having an issue with formatting a date: Code: Dim MyDate as Date MyDate = Format(Left(Now,10), "dd.mm.yy") Weirdly, this is returning MyDate as "03:06:14" rather than "03.06.14". Can anyone tell me why? Thanks!
Luke M Excel Ninja Staff member Jun 3, 2014 #2 Format is outputting a string, but you have MyDate defined as a Date, so it's getting converted back. Also, there's no need to call Now if you only want the Date. Code: Dim MyDate as String MyDate = Format(Date,"dd.mm.yy")
Format is outputting a string, but you have MyDate defined as a Date, so it's getting converted back. Also, there's no need to call Now if you only want the Date. Code: Dim MyDate as String MyDate = Format(Date,"dd.mm.yy")
Debraj Excel Ninja Jun 4, 2014 #3 Hi PipBoy808! Below will also work.. as Now can also works as Date. Code: Dim MyDate As Date MyDate = Now MsgBox Format(MyDate, "dd.mm.yy")
Hi PipBoy808! Below will also work.. as Now can also works as Date. Code: Dim MyDate As Date MyDate = Now MsgBox Format(MyDate, "dd.mm.yy")