Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting Day, Month and Year values individualy from a date

Status
Not open for further replies.

oddball

Technical User
Mar 17, 2000
64
0
0
GB
How do i get the numerical Day component from a Date variable. ie I have a variable declared, and assigned a value as below:

===========================================================

Dim dateofbirth as Date

Dim users As New ASPNetPortal.UsersDB()
Dim dr_id As SqlDataReader = users.GetSingleUser(UserEmail)

dr_id.Read()

dateofbirth = CDate(dr_id("DOB"))

dr_id.Close()

dob01.SelectedIndex = ?????????????????

===========================================================

I know need to use the Day value to set the SelectedIndex of a DropDownList, and then do the same for the Month and Year.

Thanks for any help,

cheers,

si
 
I may be confused as to your question, but won't dateofbirth.day give you the numerical day from your date variable?
 
You can use the Day, month and year methods of the datetime time.

Dim MyDate As DateTime
Dim MyDay As Integer
Dim MyMonth As Integer
Dim MyYear As Integer
MyDay = dateofbirth.Day
MyMonth = dateofbirth.Month
MyYear = dateofbirth.Year


Hope this helps. NetAngel
 
Great, didn't know it was as simple as that,

cheers,

si
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top