SQL.ConvertDateTimeToSQL
------------------------

Converts a date/time/timestamp to SQL text.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [SQL](component_SQL.md) | [11.2](newinversion112.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "SQL.ConvertDateTimeToSQL"; Value ) 

**MBS**( **"SQL.ConvertDateTimeToSQL";** /\* Converts a date/time/timestamp to SQL text. \*/  
**$Value**) /\* The date, time or timestamp value.  
Text or number are converted by FileMaker to get a timestamp.e.g. Get(CurrentDate ) \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Value | The date, time or timestamp value.   Text or number are converted by FileMaker to get a timestamp. | Get(CurrentDate ) |

### Result

Returns text or error.

### Description

Converts a date/time/timestamp to SQL text.  
Localization of FileMaker time and date formats applies. Examples below are in German format.  
  
Similar function is used internally by [SQL.SetParamValue](SQLSetParamValue.md), [SQL.SetParamAsDate](SQLSetParamAsDate.md), [SQL.SetParamAsDateTime](SQLSetParamAsDateTime.md) and [SQL.SetParamAsTime](SQLSetParamAsTime.md) to convert values automatically for you.  
### Examples

Query date:

 MBS ( "SQL.ConvertDateTimeToSQL"; Get(CurrentDate ))  
<small>  
Example result: 2021-04-27</small>Query time:

 MBS ( "SQL.ConvertDateTimeToSQL"; Get(CurrentTime ))  
<small>  
Example result: 15:45:26</small>Query timestamp:

 MBS ( "SQL.ConvertDateTimeToSQL"; Get(CurrentTimestamp ))  
<small>  
Example result: 2021-04-27T15:45:44</small>Query with text:

 MBS ( "SQL.ConvertDateTimeToSQL"; "27.04 .2021 15:46:20,123456" )  
<small>  
Example result: 2021-04-27T15:46:20.123456</small>Query with number:

 MBS ( "SQL.ConvertDateTimeToSQL"; 63346256456 )  
<small>  
Example result: 2008-05-13T06:20:56</small>### See also

- [SQL.ConvertDateTimeFromSQL](SQLConvertDateTimeFromSQL.md)
- [SQL.SetParamAsDate](SQLSetParamAsDate.md)
- [SQL.SetParamAsDateTime](SQLSetParamAsDateTime.md)
- [SQL.SetParamAsTime](SQLSetParamAsTime.md)
- [SQL.SetParamValue](SQLSetParamValue.md)

### Release notes

- **Version 11.2**
    - Added milliseconds for [SQL.ConvertDateTimeFromSQL](https://www.mbsplugins.eu/SQLConvertDateTimeFromSQL.shtml) and [SQL.ConvertDateTimeToSQL](https://www.mbsplugins.eu/SQLConvertDateTimeToSQL.shtml) functions.
    - Added [SQL.ConvertDateTimeFromSQL](https://www.mbsplugins.eu/SQLConvertDateTimeFromSQL.shtml) and [SQL.ConvertDateTimeToSQL](https://www.mbsplugins.eu/SQLConvertDateTimeToSQL.shtml) functions.

### Blog Entries

- [New in MBS FileMaker Plugin 11.2](https://www.mbsplugins.de/archive/2021-05-26/New_in_MBS_FileMaker_Plugin_11/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 11.2pr6](https://www.mbsplugins.de/archive/2021-05-04/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 11.2pr5](https://www.mbsplugins.de/archive/2021-05-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 27th April 2021 , last changed 3th May 2021

  
[SQL.ConvertDateTimeFromSQL](SQLConvertDateTimeFromSQL.md) - [SQL.Disconnect](SQLDisconnect.md)

[HTML Version](SQLConvertDateTimeToSQL.shtml)