Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

using date times in vb.net program

Posted on 2013-12-16
3
374 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

840 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