Solved

using date times in vb.net program

Posted on 2013-12-16
3
361 Views
Last Modified: 2014-01-06
I have a program that compares the date of an invoice to the date using
mydate as date = now

The program I realize is that if the user changes their system date, then that is the date that will be pulled from this line of code.

I know I can use  a getdate() statement and get it from my sql server, but I was wondering what the correct way is to handle this problem.

thanks
0
Comment
Question by:mgmhicks
3 Comments
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 39722409
Is this an ASP.net web forms application/site ? If so getting the current date on the code-behind pages or a business layer class is the recommended method as this will use the date/time from the IIS server rather than the client.
If it is a windows forms application then getting the date on the SQL Server is probably the best and most reliable method as client dates can be suspect, and also problematic if the application is used by clients in differing time zones.
0
 
LVL 16

Expert Comment

by:Kamal Khaleefa
ID: 39723593
try to set a unique format for you date
or in your code behind format the date like this

   dim ExpiryDate as date = DateTime.ParseExact(MyTextBoxID.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture)
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 39724543
>The program I realize is that if the user changes their system date, then that is the date that will be pulled from this line of code.


One option is to use a date server on the net to get the date

http://www.codeproject.com/Tips/356303/How-to-get-server-side-date-time-without-your-own
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now