Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Databases
»
[SOLVED]DATEPART fails- New to Lazarus
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
FPC 3.2.4-rc1 available
by
440bx
[
Today
at 06:08:35 am]
TChart how setup nicestep...
by
eldonfsr
[
Today
at 05:18:14 am]
I hope FreePascal can sup...
by
xiyi0616
[
Today
at 04:27:17 am]
AI assisted translation o...
by
schuler
[
Today
at 03:07:59 am]
Little bit...
by
ASerge
[
Today
at 12:48:46 am]
Can I get the position an...
by
wp
[
Today
at 12:23:04 am]
Translate .lfm file in a ...
by
wp
[
Today
at 12:07:11 am]
Playing video without to ...
by
n7800
[April 17, 2026, 11:51:39 pm]
Delimited text - how find...
by
n7800
[April 17, 2026, 11:28:25 pm]
overloading issues fpc3.2...
by
Martin_fr
[April 17, 2026, 10:21:07 pm]
Ann: Deinline: a de-inlin...
by
LeP
[April 17, 2026, 09:58:08 pm]
FPC Unleashed (inline var...
by
440bx
[April 17, 2026, 08:38:11 pm]
Seeking advice on setting...
by
schuler
[April 17, 2026, 03:36:28 pm]
Ann: DeCoperators
by
DomingoGP
[April 17, 2026, 03:23:39 pm]
Error: Compilation raised...
by
marcov
[April 17, 2026, 02:44:06 pm]
TLazSerial : serial port ...
by
CM630
[April 17, 2026, 09:50:34 am]
[Solved] Help needed comp...
by
landolfi
[April 17, 2026, 02:45:10 am]
DataPort or Synpase stat...
by
eldonfsr
[April 16, 2026, 11:32:18 pm]
[FPC 3.2.4, Windows] PTC ...
by
Fred vS
[April 16, 2026, 08:26:24 pm]
Cannot build Units for Si...
by
NormanDunbar
[April 16, 2026, 07:39:07 pm]
IDE: Property editor does...
by
dsiders
[April 16, 2026, 07:04:22 pm]
What is wrong with this c...
by
OH1KH
[April 16, 2026, 04:32:48 pm]
[work arounded]Naming dae...
by
LeP
[April 16, 2026, 03:36:10 pm]
Lazarus Bugfix Release 4....
by
Jonax
[April 16, 2026, 03:06:25 pm]
CudaText editor (written ...
by
AlexTP
[April 16, 2026, 10:43:12 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [SOLVED]DATEPART fails- New to Lazarus (Read 924 times)
What I can do
Full Member
Posts: 193
[SOLVED]DATEPART fails- New to Lazarus
«
on:
September 01, 2024, 07:33:50 pm »
OS:Windows 10@64
Lazarus:3.22
DB with *.mdb Access@32 bit
Project: Make a new temp Field upon query call
"aYMDate"
but all attempts failed,
Code: Pascal
[Select]
[+]
[-]
SQLQuery1
.
Close
;
SQLQuery1
.
SQL
.
Text
:
=
'SELECT *, DATEPART('
yyyy
',ck_Date) as aYMDate From mytable'
;
SQLQuery1
.
ExecSQL
;
SQLQuery1
.
Open
;
«
Last Edit: September 02, 2024, 07:29:36 am by What I can do
»
Logged
tooldeveloper
Newbie
Posts: 5
Re: DATEPART fails- New to Lazarus
«
Reply #1 on:
September 02, 2024, 04:33:46 am »
Try the following instead:
Code: Pascal
[Select]
[+]
[-]
SQLQuery1
.
Close
;
SQLQuery1
.
SQL
.
Text
:
=
'SELECT *, DATEPART('
'yyyy'
',ck_Date) as aYMDate From mytable'
;
SQLQuery1
.
Open
;
The 'yyyy' needs two single quotes at beginning and end. The ExecSQL method is only for executing a statement that doesn't return a result.
«
Last Edit: September 02, 2024, 04:44:20 am by tooldeveloper
»
Logged
What I can do
Full Member
Posts: 193
Re: DATEPART fails- New to Lazarus
«
Reply #2 on:
September 02, 2024, 04:55:30 am »
Thank you tooldeveloper
but...
Code: Pascal
[Select]
[+]
[-]
SQLQuery1
.
SQL
.
Text
:
=
'SELECT *, DATEPART('
'yyyy'
',ck_Date) as aYMDate From mytable'
;
Tried two apostrophe and even tried quota but errored out both times
Logged
paweld
Hero Member
Posts: 1598
Re: DATEPART fails- New to Lazarus
«
Reply #3 on:
September 02, 2024, 07:30:39 am »
In MS Access, use quotation marks instead of an apostrophe as a string delimiter
Code: Pascal
[Select]
[+]
[-]
SQLQuery1
.
SQL
.
Text
:
=
'SELECT *, DATEPART("yyyy",ck_Date) as aYMDate From mytable'
;
https://www.w3schools.com/Sql/func_msaccess_datepart.asp
Logged
Best regards / Pozdrawiam
paweld
What I can do
Full Member
Posts: 193
Re: [SOLVED]DATEPART fails- New to Lazarus
«
Reply #4 on:
September 02, 2024, 07:34:22 am »
Thank you, paweld
My problem was bad data.
I needed some working examples so I use ChatGPT to write some and it worked great.
«
Last Edit: September 02, 2024, 07:42:35 am by What I can do
»
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Databases
»
[SOLVED]DATEPART fails- New to Lazarus
TinyPortal
© 2005-2018