Since the database field is a datetime datatype and I am converting the current date to string format, this is not working.. how can I do this? I am doing the string format because I want the date in mm/dd/yyyy format and not in mm/dd/yyyy hh:mm:ss time format..
i want show date like dd/mm/yyyy
but i dont why timestamp is showing like
dd/mm/yyyy 3:00 PM
(item.linedeptdt != null)

Vishal JoshiRank #377 · 6.7K reputationPosted Jun 11, 2024, 7:29 AM EDT
Hello
you can try the below code to get expected result
Thanks
Vishal Joshi
Mukesh SagarRank #640 · 3.8K reputationPosted Jun 11, 2024, 7:25 AM EDT
use this : SELECT CAST(GETDATE() AS date) AS DateOnly;
Amit MohantyRank #112 · 20K reputationPosted Jun 11, 2024, 7:29 AM EDT
If you prefer to handle the date formatting on the database side, you can use SQL queries to format the date before it is retrieved by your application.
SELECT COLUMN_NAME, FORMAT(linedeptdt, 'dd/MM/yyyy') AS FormattedDate FROM YourTableNameMrunali SawantRank #763 · 3K reputationPosted Jun 11, 2024, 8:09 AM EDT
To display only the date part from a
datetimefield indd/MM/yyyyformat in ASP.NET, you can use theToStringmethod with a format string in your Razor view.