Solved

Min Date?

Posted on 2014-10-31
5
325 Views
Last Modified: 2014-11-03
C# / .NET  /  AngularJS  /  JSON:


If I am passing a DateTime value as a parameter ... how do I get "MinDate" such that SQL Server (T-SQL) will consume it and JSON will translate it?

In other words, this is what I have been passing:

 ticketList = _esnService.ECIDHDTicketList(userProfile.VendorID,
                    userProfile.PublicAPICompany,
                    "",
                    userProfile.PublicAPIUsername,
                    userProfile.PublicAPIPassword,
                    "",
                    "BB00",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    DateTime.Parse("2009-03-13 22:16:00"),
                    "",
                    true);

Open in new window




Notice this param:

                    DateTime.Parse("2009-03-13 22:16:00"),


I want to do the same thing, but using something more generic, like "MinDate( )" or something or other.  I want to stop hard-coding the string that represents the datetime value.
0
Comment
Question by:knowlton
5 Comments
 
LVL 23

Assisted Solution

by:Ioannis Paraskevopoulos
Ioannis Paraskevopoulos earned 25 total points
ID: 40416945
Have you tried DateTime.Now

It will always fetch the current date and time at the time you request it. Both SQL and javascript should be able to handle it.
0
 
LVL 78

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 25 total points
ID: 40417182
date mindate = datetime.now.adddays(-365)   ' a year ago
0
 
LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 50 total points
ID: 40417187
If MinDate is always the same date, then simply write a method^

		public DateTime MinDate()
		{
			return (DateTime.Parse("2009-03-13 22:16:00"));
		}

Open in new window


 and call it:

      ...
      "",
      MinDate(),
      "",
     true);
0
 
LVL 11

Accepted Solution

by:
Mihai Stancescu earned 400 total points
ID: 40417926
Hi,

If you really want min date for SQL Server you can use: SqlDateTime.MinValue (in System.Data.dll).
Notice that SQL MinDate is different than C# min date. Sql Min Date is 1st January 1753.

Hope this helps!

Regards,
Mishu
0
 
LVL 5

Author Closing Comment

by:knowlton
ID: 40419695
thx
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Hovering effect 9 29
Installing IIS after Visual Studio 2015 Community Edition 5 16
Create XML 5 31
Re-position the objects 7 49
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 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

15 Experts available now in Live!

Get 1:1 Help Now