Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 515
  • Last Modified:

Change time part of datetime field in vb.net

Hello Experts,

I need to change part of a date field......

If i have 2014-01-31 08:59.17 for instance, how can i change it to 2014-01-31 07:00:00.

The date field will be a variable but the time i want to change it to will always be fixed.

Thanks in advannce
0
SweetingA
Asked:
SweetingA
1 Solution
 
Jacques Bourgeois (James Burger)PresidentCommented:
Once your field is loaded in a Date variable called d:

d = d.Date.AddHours(7)
0
 
Éric MoreauSenior .Net ConsultantCommented:
YourDate = new datetime(YourDate.Year, YourDate.Month, YourDate.Day).AddHours(7)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now