DNR
DNR

Reputation: 3736

Separating Date and Time values from SQL Server 2008 to display in asp.net

I have a database table that stores a datetime value.
I want to display that value on my asp.net textboxes, except I need to show date value in TextBox A and Time in TextBox B.

How can I split those values in VB.NET?

Upvotes: 1

Views: 2929

Answers (2)

PaulStock
PaulStock

Reputation: 11263

You can use the built in date formatting functions in VB:

Dim ThisDate as DateTime = Now

Dim TimePart as string = ThisDate.ToShortTimeString
dim DatePart as string = ThisDate.ToShortDateString

Upvotes: 0

sll
sll

Reputation: 62484

The idea is to use format string:

  • Date: dateTimeReadedFromDb.ToString("dd-MM-yyyy")
  • Time: dateTimeReadedFromDb.ToString("hh:mm:ss")

Upvotes: 4

Related Questions