Now() - Show Month and Day only - Microsoft Access
12,891
Solution 1
If you are looking for a function that will return the date in the format day-month, then you can do the following:
Public Function test()
Dim testdate As String
test = Format(Day(Now()), "00") & "-" & Format(Month(Now()), "00")
End Function
Result:
29-04
If you wanted to use the date format in a query, you could just do:
select (Format(Day(Now()), "00") & "-" & Format(Month(Now()), "00")) as DayMonth
From yourtable
or
select (Format(Now(), "dd-mm")) as DayMonth
From yourtable
Solution 2
Example: a field in your table is DOB and then you need it to output only Day and Month only. So you need to choose data type Date/Time and then you should Format is where field properties and in general tab and then input like this: dd-mmmm
hope it can help you.
Author by
user1325927
Updated on June 21, 2022Comments
-
user1325927 almost 2 years
When I use this function in Access: Now() it returns this: 27-04-2012 10:03:09
How can I make a function that only show month and date like this: 27-04
-
user1325927 about 12 yearsCool that works in Access, but when I extract the date on my website, it shows with year, hour, minute and seconds :(
-
Eric about 12 yearssorry i know only in access. but i think that when you extract the date on your website, maybe you should format it again.
-
Taryn about 12 years@HansUp because I was half-asleep when I wrote it and wasn't thinking obviously. :) Updated to add that query.