How to get only date


#1

I am using datetime function to get the date but i dont want time. How to get only date?


#2

Date.Now.toString("dd")

dd - date
MM - Month (01, 02 )
MMM - Month (JAN,FEB)
yy - year( 17,18)
yyyy - year (2017.2018)


#3

If today’s date is 18/1/2018 but i have to work on yesterday’s date, how to write complete expression.I want to know the dynamic expression as my process demands to work on previous date. Please help.


#4

Date.Now.addDays(-1).toString("dd")


#5

thanks buddy


#6

hi guys how can you get the name of the day


#7

Hi @Jonga2018,

System.DateTime.Now.DayOfWeek.ToString()
Or
System.DateTime.Now.ToString("dddd")
Or
System.DateTime.Now.ToString("ddd")

Regards,
Arivu


#8

Here is the full list of the VB.NET datetime formats you can get when you use datetime.tostring(“xxxx”)

https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings


#9

You can use,

DateTime.Now.ToShortDateString
(or)
Date.Now.ToShortDateString

If u give variable type as Generic.