Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. get datetime values from database in dd/MM/yyyy HH:mm:ss format irrespective of system date/time format

get datetime values from database in dd/MM/yyyy HH:mm:ss format irrespective of system date/time format

Scheduled Pinned Locked Moved C#
databasetutorialcsharpsql-serversysadmin
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NarVish
    wrote on last edited by
    #1

    I run the below query in SQL server through C#. SELECT ScheduleTime FROM test I'm using SqlDataAdapter to fill the results in datatable. I'm getting "ScheduleTime" values from test table ("ScheduleTime" is datetime type). But the results are in system date time format. For example, if my system Time format is "tt hh:mm:ss" in Long Time, the results are in the below format. 27-03-2013 PM 03:51:01 if my system Time format is "HH:mm:ss" in Long Time, the results are in the below format. 27-03-2013 15:51:01 I need to get the results in dd/MM/yyyy HH:mm:ss format irrespective of system date/time format. Please guide me to this. Thanks in advance.

    H 1 Reply Last reply
    0
    • N NarVish

      I run the below query in SQL server through C#. SELECT ScheduleTime FROM test I'm using SqlDataAdapter to fill the results in datatable. I'm getting "ScheduleTime" values from test table ("ScheduleTime" is datetime type). But the results are in system date time format. For example, if my system Time format is "tt hh:mm:ss" in Long Time, the results are in the below format. 27-03-2013 PM 03:51:01 if my system Time format is "HH:mm:ss" in Long Time, the results are in the below format. 27-03-2013 15:51:01 I need to get the results in dd/MM/yyyy HH:mm:ss format irrespective of system date/time format. Please guide me to this. Thanks in advance.

      H Offline
      H Offline
      Hemant Singh Rautela
      wrote on last edited by
      #2

      convert the date to show your desire format eg. DateTime dt = yourdatabasedate; string showdate = dt.ToString("dd/MM/yyyy"); for you : use this format "dd/MM/yyyy HH:mm:ss"

      N 1 Reply Last reply
      0
      • H Hemant Singh Rautela

        convert the date to show your desire format eg. DateTime dt = yourdatabasedate; string showdate = dt.ToString("dd/MM/yyyy"); for you : use this format "dd/MM/yyyy HH:mm:ss"

        N Offline
        N Offline
        NarVish
        wrote on last edited by
        #3

        Thank you, hemantrautela. Due to hectic schedule, couldn't able to solve this small issue. Thank you once again

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups