Input = str_ETADate=05/21/2023 00:00:00 string format
want output date_ETADate = 05/21/2023 datetime format
I have tried
date_ETAdate=DateTime.ParseExact(str_ETADate,“dd/MM/yyyy”,System.Globalization.CultureInfo.InstalledUICulture)
but time stamp remains same.
Please suggest solution how to remove time stame in date time format
variable.toSting.Trim.Replace(" 00:00:00",“”)
Try this
cheers
Anil_G
(Anil Gorthi)
August 13, 2023, 3:40pm
3
@satish.rathi59
If you need as string then you can get in whatever format you want…when stored as datetime or date it would have all of it
Any variable in datetime format will have date and time also…only while converting back to string you can give whatever format you need
datetimevar.ToString("MM/dd/yyyy")
Cheers
already tried but this is in string, need in date time
Hi @satish.rathi59
Cdate(datetimevar.ToString(“MM/dd/yyyy”))
Can you try this
Hope this helps you
1 Like
postwick
(Paul Ostwick)
August 13, 2023, 6:31pm
7
That format is for the ParseExact to know how the input string is formatted. So change it to include the time:
DateTime.ParseExact(str_ETADate,“dd/MM/yyyy HH:mm:ss”,System.Globalization.CultureInfo.InstalledUICulture)
Now this gives you a datetime, but you’re not formatting it on the output side, so add .ToString to it:
DateTime.ParseExact(str_ETADate,“dd/MM/yyyy”,System.Globalization.CultureInfo.InstalledUICulture).ToString(“dd/MM/yyyy”)
Note that this is not possible. A datetime doesn’t have a format, it’s an internal value type. It always internally includes the date and time. You only format it when you’re outputting it with .ToString
1 Like
Hello @satish.rathi59
please Try with this Expression:
DateTime.ParseExact(“05/21/2023 00:00:00”,“MM/dd/yyyy HH:mm:ss”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”)
1 Like
rlgandu
(Rajyalakshmi Gandu)
August 14, 2023, 7:57am
9
@satish.rathi59
Str_Date=Str_ETADate.Split(" "c)(0)
1 Like
H! @satish.rathi59
instead of doing all ,simply use this expression
Convert.ToDateTime(“05/21/2023 00:00:00”).ToString(“MM/dd/yyyy”)
for the reference check below screenshot!
2 Likes
neha.upase
(Neha Upase)
August 14, 2023, 9:16am
11
Hi,
Please try this,
str_ETADate=05/21/2023 00:00:00
DateTime.ParseExact(str_ETADate,“MM/dd/yyyy HH:mm:ss”,Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”)
1 Like
Parvathy
(PS Parvathy)
August 14, 2023, 10:05am
12
Hi @satish.rathi59
If you want the output in datetime format you will get the Time Stamp value for that. If you don’t want the time stamp value try the below syntax:
date_ETAdate=DateTime.ParseExact(str_ETADate,“MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString("MM/dd/yyyy")
The above syntax will return the output in the format MM/dd/yyyy and date_ETAdate is of datatype String.
Hope you understand!!
1 Like
system
(system)
Closed
August 17, 2023, 10:05am
13
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.