Solved

Change time part of datetime field in vb.net

Posted on 2014-02-14
2
392 Views
Last Modified: 2014-02-15
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
Comment
Question by:SweetingA
2 Comments
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
ID: 39860983
Once your field is loaded in a Date variable called d:

d = d.Date.AddHours(7)
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 39861304
YourDate = new datetime(YourDate.Year, YourDate.Month, YourDate.Day).AddHours(7)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question