SQL. How to work with dates

How to work with dates

Format used dd.mm.yyyy (if you are using a type Date selection)

In the form save procedures, pass the Date parameters as a line.

Reduction line to date: try_convert(date, isnull(@fielddateBirth,'01.01.1980'), 104)

Reduction date to line: convert(nvarchar, isnull(dateBirth,'01.01.1900'), 104)

If you use a type HTML Date, then the output and save is used as follows:

Reduction line to date: try_convert(date, isnull(@fielddateBirth,'1980-01-01'), 23)

Reduction date to line: convert(nvarchar, isnull(dateBirth,'1900-01-01'), 23)

If required in table edit Date and Time

Column type - line, type of column editing - Date and time

GetItems:

  • поле @result.started Type nvarchar(64)
  • in insert bring to the line format(started, 'dd.MM.yyyy HH:mm')

UpdateField:

  • set started = try_convert(datetime, isnull(@value,'01.01.2000 00:00'), 104)

If required on the form edit Date

Type of column - HTML5

USE rudenas2x  
GRANT EXECUTE ON OBJECT::[dbo].daily_GetExecutorsLoading
    TO falcon2;  
GO  

Date

GetItem:

convert(nvarchar,isnull(deadline,'1900-01-01'),23) as deadline

SaveItem:

deadline = try_convert(date,isnull(@fielddeadline,'1900-01-01'),23)

Format of date: https://www.mssqltips.com/sqlservertip/1145/date-and-time-conversions-using-sql-server/

Working with form fields of type DATE

If you have a field Date HTML 5 (input[type=date] used), then all dates should be led to the view YYYY-MM-DD. The example - convert(nvarchar(10), deadlineDate, 120). This is done both to load the value and to save. 

If you have a date of type Date (используется Datepicker used), you can enter the format specified in the GetLayout Info в SELECT 1 in parameter dateFormat. 

Usually it is dd.mm.yyyy. The example convert(nvarchar(10), deadlineDate, 104)

Additional

SQL-tool for creating personal accounts on the site

The essence of the approach and the history of the creation of Falcon Space
Web platform for creating personal accounts

Falcon Space Platform

This is a reduction in the cost of ownership

at the expense of fewer people to support

This is a quick change

while using the program

This is a modern interface

full adaptation for mobile devices

MS SQL web applications. Affiliate program for developers and web studios

You can develop yourself or collaborate with us for web development on the Falcon Space platform using only SQL and HTML.
View examples with SQL code
Platform documentation
Working on MS SQL Server
Component demo stand
At the stand you can see various components in action - tables, forms, modal windows, diagrams, a map, etc.
Solution demo site
Basic solutions that can be flexibly adapted for yourself - change the appearance, business logic and even the structure of the database.
Discuss the project
Ask the initial questions about the project that concern you right now. We will advise you for free and recommend the best solution.